package com.github.byakkili.bim.demo.listener;

import com.github.byakkili.bim.core.BimSession;
import com.github.byakkili.bim.core.handler.command.CommandFrame;
import com.github.byakkili.bim.core.listener.SessionListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author Guannian Li
 */
@Slf4j
@Component
public class MySessionListener implements SessionListener {
    @Override
    public void onAfterCreated(BimSession session) {
        log.info("One session created: {}", session.getId());
    }

    @Override
    public void onBeforeDestroy(BimSession session) {
        log.info("One session destroy: {}", session.getId());
    }

    @Override
    public void onReaderIdle(BimSession session) {

    }

    @Override
    public void onWriterIdle(BimSession session) {

    }

    @Override
    public void onRead(CommandFrame msg, BimSession session) {
        log.info("One session read: {}", session.getId());
    }

    @Override
    public void onWrite(CommandFrame msg, BimSession session) {
        log.info("One session write: {}", session.getId());
    }
}
